package com.example.demo.service;

import com.example.demo.mapper.UserMapper;
import com.example.demo.model.dto.UserDto;
import com.example.demo.model.po.UserPo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * create by elitetyc
 * date：2019/6/12
 * desc：
 **/
@Service
public class LoginService {

    @Autowired
    private UserMapper userMapper;

    public UserDto login(String account,String pwd){
        UserDto userDto = new UserDto();
        UserPo userPo = userMapper.selectByAccount(account);
        if (userPo==null){
            return null;
        }else {
            if (userPo.getPassword().equals(pwd)){
//                BeanUtils.copyProperties(userDto,userPo);
                BeanUtils.copyProperties(userPo,userDto);
                return userDto;
            }else {
                return null;
            }
        }
    }
}
